package written_examination;
import java.util.*;

public class Main_1128_1{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int tmp = 0;
        int right = 1;
        int left = 0;
        int num = 0;
        while(n > right){
            tmp = right + left;
            left = right;
            right = tmp;
            num = ((n - left) > (right - n)) ? (right - n) : (n - left);
        }
        System.out.println(num);
    }
}
